
var import_window;
function import_dialog(name){
  var winmgs= "<HTML>";
  winmgs+="<form><h3>Importing claim  <input type=text value=1 id=importnum></h3></form></html>";    
  alert(winmsgs);
  import_window = window.open("about:","Import "+name,"height=175,width=600");
  import_window.document.write(winmgs);
  import_window.document.close();
}

// import claims from file 

function import_claim_text_fromfile(lang) {
  //var ForWriting = 2;
  //var TriStateFalse = 0; 
  var rep=prompt("OCR File name :",GetPrefsOCRFilesDir()+"\\"+GetPrefsOCRFile());
  var gFile;
  var done="";
  //var mod=1;
  while(rep && !done) {
    while(rep && !gFile) {
      try {
	gFile = dos_open(rep,1);
      } catch(e) {
	rep=prompt("Cannot open file, retry ",rep);	
      }  
    }
    if(gFile) {
      var srctxt=gFile.Readall();
      if(GetPrefsAttr("utf8")) {
	srctxt=Utf8.decode(txt);
      }	
      var claim_iter=new iter_parse_claims(srctxt,GetClaimSetLength());
      while(!claim_iter.end()) {
	var cl=claim_iter.number();
	var txt=claim_clean(cl,claim_iter.getValue());
	//split_claim_header(cl,txt);
	if(GetFeaturesLength(cl)>1) {
	  ReplaceClaim(cl,GetClaimSetVersion());  // replace claim with empty one
	}
	SetClaimHeader(cl,""); // clear header
	SetClaimImport(cl,"");
	//SetClaimEq(cl,"");
	SetClaimVerbatim(cl,clean_text(txt,lang,"basic")); // keep copy of loaded text
	SetFeatureDesc(cl,1,GetClaimVerbatim(cl));
	SetClaimDep(cl,claim_parse(cl,txt));
	document.title="Import "+cl;
	claim_iter.next();
      }
      done="yes";
    }
  }

  ClaimToolTitle();
  return rep;
}


function do_importdesc() {
  var rep=prompt("OCR File name :",GetPrefsOCRFilesDir()+"\\"+GetPrefsOCRFile());
  var gFile;
  var done="";
  //var mod=1;
  while(!done && rep) {
    try {
      if(gFile = dos_open(rep,1)) {        
	SetDossierDescription(gFile.Readall());
	done="yes";
      }
    } catch(e) {
      rep=prompt("Cannot open file, retry ",rep);	
    }    
  }
}  

